home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / boot / avwm.lzh / avwm-0.4 / wbwm.c < prev    next >
C/C++ Source or Header  |  1994-08-08  |  3KB  |  118 lines

  1. /*
  2.     wbwm.c - Workbench Window Monitor
  3.     5/10/93 Bernhard Fastenrath
  4. */
  5.  
  6. #include <dos.h>
  7. #include <signal.h>
  8. #include <exec/types.h>
  9. #include <intuition/intuition.h>
  10. #include <pragmas/exec_pragmas.h>
  11. #include <pragmas/intuition_pragmas.h>
  12.  
  13. #include "wbwm.h"
  14. #include "jumptable.h"
  15.  
  16. #if 0
  17. #define SEM_P struct SignalSemaphore *jt;\
  18. if (jt = FindSemaphore (JTName))\
  19.   ObtainSemaphoreShared (jt);\
  20. else\
  21.   return NULL
  22. #define SEM_V ReleaseSemaphore (jt)
  23. #else
  24. #define SEM_P while(0)
  25. #define SEM_V while(0)
  26. #endif
  27.  
  28. DECLARE (CloseWindow)
  29. DECLARE (MoveWindow)
  30. DECLARE (OpenWindow)
  31. DECLARE (SizeWindow)
  32. DECLARE (WindowToBack)
  33. DECLARE (WindowToFront)
  34. DECLARE (ActivateWindow)
  35. DECLARE (MoveWindowInFrontOf)
  36. DECLARE (ChangeWindowBox)
  37. DECLARE (ZipWindow)
  38. DECLARE (OpenWindowTagList)
  39.  
  40. extern UBYTE *JTName;
  41. extern struct IntuitionBase *IntuitionBase;
  42. extern ULONG WMSig;
  43. struct LVOTable LVOArray[] = { FUNCTIONS };
  44. static int event[] = { WINDOW_EVENTS };
  45. static int monitor_on = 0;
  46. static struct Task *my_task = NULL;
  47.  
  48. int
  49. start_window_monitor ()
  50. {
  51.   monitor_on = 1;
  52.   my_task = FindTask (NULL);
  53.   return InstallWedge ();
  54. }
  55.  
  56. void
  57. stop_window_monitor ()
  58. {
  59.   if (monitor_on)
  60.   {
  61.      monitor_on = 0;
  62.      RemoveWedge ();
  63.   }
  64. }
  65.  
  66. /* It wouldn't be a good idea to call other functions because this
  67.    code may be executed by any task and the other task's stack is used.
  68. */
  69. void __saveds monitor_event (int event) { Signal (my_task, WMSig); }
  70.  
  71. /*
  72.  *    Intercepting Functions
  73.  */
  74.  
  75. LONG ASM
  76. CloseWindowR (ARGS)
  77. { int x; SEM_P; x = CloseWindowO (ALIST); monitor_event ( WE_CloseWindow ); SEM_V; return x; }
  78.  
  79. LONG ASM
  80. MoveWindowR (ARGS)
  81. { int x; SEM_P; x = MoveWindowO (ALIST); monitor_event ( WE_MoveWindow ); SEM_V; return x; }
  82.  
  83. LONG ASM
  84. OpenWindowR (ARGS)
  85. { int x; SEM_P; x = OpenWindowO (ALIST); monitor_event ( WE_OpenWindow ); SEM_V; return x; }
  86.  
  87. LONG ASM
  88. SizeWindowR (ARGS)
  89. { int x; SEM_P; x = SizeWindowO (ALIST); monitor_event ( WE_SizeWindow ); SEM_V; return x; }
  90.  
  91. LONG ASM
  92. WindowToBackR (ARGS)
  93. { int x; SEM_P; x = WindowToBackO (ALIST); monitor_event ( WE_WindowToBack ); SEM_V; return x; }
  94.  
  95. LONG ASM
  96. WindowToFrontR (ARGS)
  97. { int x; SEM_P; x = WindowToFrontO (ALIST); monitor_event ( WE_WindowToFront ); SEM_V; return x; }
  98.  
  99. LONG ASM
  100. ActivateWindowR (ARGS)
  101. { int x; SEM_P; x = ActivateWindowO (ALIST); monitor_event ( WE_ActivateWindow ); SEM_V; return x; }
  102.  
  103. LONG ASM
  104. MoveWindowInFrontOfR (ARGS)
  105. { int x; SEM_P; x = MoveWindowInFrontOfO (ALIST); monitor_event ( WE_MoveWindowInFrontOf ); SEM_V; return x; }
  106.  
  107. LONG ASM
  108. ChangeWindowBoxR (ARGS)
  109. { int x; SEM_P; x = ChangeWindowBoxO (ALIST); monitor_event ( WE_ChangeWindowBox ); SEM_V; return x; }
  110.  
  111. LONG ASM
  112. ZipWindowR (ARGS)
  113. { int x; SEM_P; x = ZipWindowO (ALIST); monitor_event ( WE_ZipWindow ); SEM_V; return x; }
  114.  
  115. LONG ASM
  116. OpenWindowTagListR (ARGS)
  117. { int x; SEM_P; x = OpenWindowTagListO (ALIST); monitor_event ( WE_OpenWindowTagList ); SEM_V; return x; }
  118.